#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
typedef long long ll;
const int N = 100005;

int n;
ll a[N], val[N << 2];

inline ll read() {
  ll x = 0;
  int ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return x;
}

inline void pushup(int x) { val[x] = val[x << 1] + val[x << 1 | 1]; }

void build(int x, int l, int r) {
  if (l == r) {
    val[x] = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  pushup(x);
}

void modify(int x, int l, int r, int L, int R) {
  if (val[x] == r - l + 1) return;
  if (l == r) {
    val[x] = sqrt(val[x]);
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) modify(x << 1, l, mid, L, R);
  if (mid < R) modify(x << 1 | 1, mid + 1, r, L, R);
  pushup(x);
}

ll query(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) return val[x];
  int mid = (l + r) >> 1;
  ll res = 0;
  if (L <= mid) res += query(x << 1, l, mid, L, R);
  if (mid < R) res += query(x << 1 | 1, mid + 1, r, L, R);
  return res;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("seven.in", "r", stdin);
  freopen("seven.out", "w", stdout);
#endif
#endif

  n = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
  }
  build(1, 1, n);
  int m = read(), k, l, r;
  while (m--) {
    k = read(), l = read(), r = read();
    if (l > r) std::swap(l, r);
    if (k) {
      printf("%lld\n", query(1, 1, n, l, r));
    } else {
      modify(1, 1, n, l, r);
    }
  }
  return 0;
}